﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Rhino.Mocks;
using WebFormsMvp.Contrib.Views;
using WebFormsMvp.Contrib.Presenters;

namespace WebFormsMvp.Contrib.Tests
{
    [TestClass]
    public class FeedbackPresenterTests
    {
        [TestMethod]
        public void Submit_Handler_Executed_In_Presenter()
        {
            //Arrange
            var view = MockRepository.GenerateMock<IFeedbackView>();
            var presenter = MockRepository.GenerateMock<FeedbackPresenter>(new object[] { view });
            var e = new FeedbackEventArgs();
            presenter.Expect(p => p.View_Submit(Arg<object>.Is.Anything, Arg<FeedbackEventArgs>.Is.Equal(e)));

            //Act
            view.Raise(v => v.Load += null, this, EventArgs.Empty);
            view.Raise(v => v.Submit += null, this, e);

            //Assert
            view.VerifyAllExpectations();
            presenter.VerifyAllExpectations();
        }
    }
}
